package com.xjh.him.netty;

import com.xjh.him.domain.UserDO;
import com.xjh.him.netty.codec.Packet;
import io.netty.channel.Channel;
import io.netty.util.AttributeKey;

import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class NettyCore {
    /**
     * 标识分组是否使用本项目协议
     */
    public static final byte MAGIC_NUM = 36;

    /**
     * netty LengthFieldDecoder 最大消息长度
     */
    public static final int MAX_FRAME_LENGTH = Integer.MAX_VALUE;

    /**
     * netty LengthFieldDecoder 报文中长度字段偏移量
     */
    public static final int LENGTH_FIELD_OFFSET = 2;

    /**
     * netty LengthFieldDecoder 长度字段大小
     */
    public static final int LENGTH_FIELD_LENGTH = 4;

    /**
     * channel的属性参数
     */
    public static final String CHANNEL_KEY_NAME = "channel_user_do";
    public static final AttributeKey<UserDO> CHANNEL_KEY = AttributeKey.newInstance(CHANNEL_KEY_NAME);

    /**
     * 在线用户ID和通道映射
     */
    public static final ConcurrentHashMap<Long, Channel> ACTIVE_USER_CHANNEL = new ConcurrentHashMap<>();

    /**
     * 缓存消息
     */
    public static final ConcurrentHashMap<Integer, List<Packet>> CACHE_PACKET_LIST_MAP = new ConcurrentHashMap<>();


    public static void sendMsg(Long senderId, Long receiverId) {

    }
}
